<template>
	<view class="user-container">
		<!-- 顶部用户信息 -->

		
		<view class="user-info" >
			<view style="display: flex; align-items: center;">
				<image class="avatar" :src="userInfo.user_pic" @click="login" v-if="userInfo && userInfo.user_pic" mode="aspectFill" style="width: 60px; height: 60px; margin-right: 20px;"></image>
				<image src="/static/logo.png" mode="aspectFill" v-else style="width: 60px; height: 60px; margin-right: 20px;"></image>
				<view class="text" v-if="userInfo && userInfo.phoneNum">{{userInfo.phoneNum}}</view>
				<view class="text" @click="navigateTo('/pages/login/login')" v-else>点击登录</view>
			</view>
			<view class="iconfont icon-shezhi" @click="toMyset"></view>
			<!-- <view class="nickname-container">
				<navigator  url="/pages/mySet/mySet"> <text  class="nickname">昵称: {{ userInfo.nickname }}</text></navigator>
				
			</view> -->
			<view class="form-title" style="display: flex; justify-content: flex-end; margin-left: auto;">
					<navigator  url="/pages/mySet/mySet">
						<!-- <span class="iconfont icon-mti-shezhi"></span> -->						
					</navigator>
			</view>
				
			<navigator  url="/pages/mySet/mySet">
			<image class="set" src='/static/images/设置1.png' url="/pages/mySet/mySet"></image>
			</navigator>
			
		</view>

		<!-- 菜单列表 -->
		<view class="menu-list">
			<!-- 申请接单 -->
			<view class="menu-item" @tap="navigateTo('/pages/apply/apply')">
				<view class="left">
					<image class="icon" src="/static/images/订单1.png"></image>
					<text>申请接单</text>
				</view>
				<image class="arrow" src="/static/images/箭头.png"></image>
			</view>

			<!-- 提示文本 -->
			<view class="tips">
				问题请点击微信客服复制微信添加好友
			</view>

			<!-- 微信客服 -->
			<view class="menu-item" @tap="contactService">
				<view class="left">
					<image class="icon" src="/static/images/微信客服.png"></image>
					<text>微信客服</text>
				</view>
				<image class="arrow" src="/static/images/箭头.png"></image>
			</view>

			<!-- 关于我们 -->
			<view class="menu-item" @tap="navigateTo('/pages/aboutAs/aboutAs')" >
				<view class="left">
					<image class="icon" src="/static/images/关于我们.png"></image>
					<text>关于我们</text>
				</view>
					<image class="arrow" src="/static/images/箭头.png"></image>
			</view>

			<!-- 投诉建议 -->
			<view class="menu-item" @tap="navigateTo('/pages/proposal/proposal')">
				<view class="left">
					<image class="icon" src="/static/images/投诉建议.png"></image>
					<text>投诉建议</text>
				</view>
				<image class="arrow" src="/static/images/箭头.png"></image>
			</view>
		</view>

		<!-- 修改密码按钮 -->
		<view class="goUpdatePwd" @tap="goUpdatePwd">
			修改密码
		</view>

		<!-- 退出登录按钮 -->
		<view class="logout-btn" @tap="logout"  v-if="userInfo.phoneNum">
			退出登录
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: null
			}
		},
		created() {
			// 获取存储在storage中的userInfo数据name userInfo
			this.userInfo = uni.getStorageSync("userInfo")
			
			let obj = {
				name:"LJY",
				age:18,
				name:"LLL"
			}
			let obj1 = {...obj,name:"LLL"}
			console.log(obj,obj1,"obj对象");
			
			let arr = [1,2,3]
			
			let arr1 = arr
			arr[0] = 999
			
			console.log(arr,arr1,"arr数组");
		},
		methods: {
			
				
			goUpdatePwd(){
				uni.navigateTo({
					url:'/pages/updatedPassword/updatedPassword',
					
				})
			},
			
			navigateTo(url) {
				uni.navigateTo({
					url
				})
			},
			contactService() {
				// 实现客服联系逻辑
				uni.setClipboardData({
					data: 'your-wechat-id',
					success: () => {
						uni.showToast({
							title: '微信号已复制',
							icon: 'none'
						})
					}
				})
			},
			logout() {
				uni.showModal({
					title: '提示',
					content: '确定要退出登录吗？',
					success: (res) => {
						if (res.confirm) {
							uni.clearStorageSync()
							uni.reLaunch({
								url: '/pages/login/login'
							})
						}
					}
				})
			}
		},
		onLoad() {
			// 获取存储的用户信息
			const userInfo = uni.getStorageSync('userInfo')
			if (userInfo) {
				this.userInfo = userInfo
			}
		}
	
	
		// set(){
		// 	url:"/pages/mySet/mySet"
		// }
	}
</script>

<style lang="scss">
	.user-info{
		.set{
			position: absolute;
			right: 20px;
			width: 20px;
			height: 20px;
		}
		.avatar {
			width: 200rpx;
			height: 200rpx;
			border-radius: 50%;
			margin-right: 15px;
		}
	}
	.user-container {
		min-height: 100vh;
		background-color: #f5f5f5;
		
		.user-info {
			position: relative;
			padding: 20px;
			background-color: #fff;
			display: flex;
			align-items: center;
			
			// .avatar {
			// 	width: 120rpx;
			// 	height: 120rpx;
			// 	border-radius: 50%;
			// 	margin-right: 15px;
			// }
			
			.nickname {
				font-size: 16px;
			}
			
			.settings-icon {
				position: absolute;
				right: 20px;
				width: 20px;
				height: 20px;
			}
		}
		
		.menu-list {
			margin-top: 10px;
			
			.menu-item {
				display: flex;
				align-items: center;
				margin-bottom: 30rpx;
				background: rgba(255, 255, 255, 0.8);
				padding: 20rpx;
				border-radius: 12rpx;
				box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.1);
				
				.left {
					display: flex;
					align-items: center;
					
					.icon {
						width: 20px;
						height: 20px;
						margin-right: 10px;
					}
				}
				
				.arrow {
					width: 15px;
					height: 15px;
				}
			}
			
			.tips {
				padding: 10px 20px;
				color: #666;
				font-size: 14px;
				background-color: #e8f0fe;
			}
		}
		
		.logout-btn {
			margin: 20px;
			height: 44px;
			line-height: 44px;
			text-align: center;
			background-color: #e54d42;
			color: #fff;
			border-radius: 4px;
		}
		
		.tab-bar {
			position: fixed;
			bottom: 0;
			left: 0;
			right: 0;
			height: 50px;
			background-color: #fff;
			display: flex;
			border-top: 1px solid #eee;
			
			.tab-item {
				flex: 1;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				
				image {
					width: 24px;
					height: 24px;
				}
				
				text {
					font-size: 12px;
					margin-top: 2px;
				}
				
				&.active {
					color: #e54d42;
				}
			}
		}
	}
</style>
